// RealPlay Ltd  copyrights.
// This program is Open Source AsIs
// You may use it for all purposes, including commercial
// But!!!
// If you use any part of this code, you must state clearly
// both in your source file and in the Help|about of your program,
// that the origin program or code was built by RealPlay Ltd

// ***********************************************************************/
// *                                                                     */
// *        This unit is the Tools Frame  for  "Paint" Program           */
// *                                                                     */
// ***********************************************************************/

unit UPTools;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Buttons, StdCtrls, ExtCtrls, UPFrToolOptions;

type
  TFrTools = class(TFrame)
    SBNone: TSpeedButton;
    SBa1: TSpeedButton;
    SBb1: TSpeedButton;
    SBa2: TSpeedButton;
    SBb2: TSpeedButton;
    SBa3: TSpeedButton;
    SBb3: TSpeedButton;
    SBa4: TSpeedButton;
    SBb4: TSpeedButton;
    SBa6: TSpeedButton;
    SBb5: TSpeedButton;
    FontDialog1: TFontDialog;
    SBb7: TSpeedButton;
    SBa7: TSpeedButton;
    SBb8: TSpeedButton;
    SBa8: TSpeedButton;
    SBa5: TSpeedButton;
    SBb6: TSpeedButton;
    FrameToolOption1: TFrameToolOption;
    procedure ToolMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure SBb5Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
    procedure ToolSelect(Sender: TObject);
  end;

implementation

uses UPMain, UPUtil, UPScaleDlg, UPFloodfill;
{$R *.dfm}

procedure TFrTools.ToolSelect(Sender: TObject);
begin
  ToolMouseDown(Sender, mbLeft, [], 0, 0);
end;

procedure TFrTools.ToolMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  with FPaint do
  begin
    FWA.ZF.GetN;
    FWA.Clear;
    tool := (Sender as TSpeedButton).tag;
    FrameToolOption1.SetTool(tool);
    if tool = crTrans then
      SBNone.down := true
    else if tool <> crNone then
      FrRTool1.SB2None.down := true;
    FWA.Im.Cursor := tool;
    Application.ProcessMessages;
    { with FWA do case tool of
      crNone        : Im.Cursor:=crDefault;
      crCatchS      : Im.Cursor:=crCross;
      crCatch       : Im.Cursor:=crCross;
      crErasor      : Im.Cursor:=crCross;
      crBin         :
      if (Button=mbRight) then FBinDepthDlg.ShowModal
      else Im.Cursor:=crBin;
      crPipet       : Im.Cursor:=crPipet;
      crMag         :
      if (Button=mbRight) then FScaleDlg.ShowModal
      else Im.Cursor:=crCross;
      crPen         : Im.Cursor:=crPen;
      crBrush       : Im.Cursor:=crCross;
      crLine        : Im.Cursor:=crCross;
      crText        : Im.Cursor:=crIBeam;
      crTrans       : Im.Cursor:=crTrans;
      end;  //case }
  end; // with
end;

procedure TFrTools.SBb5Click(Sender: TObject);
begin
  if FontDialog1.Execute then
    FPaint.Font := FontDialog1.Font;
end;

end.
